#ifndef LOGIN-LY_H
#define LOGIN-LY_H

#define LOAD_CFG_VARIANT(x) cfg.value(#x)
#define SAVE_CFG_VARIANT(x) cfg.setValue(#x, x)

#include "SignUpWidget.h"
#include "StudentWidget/studentwidget.h"

#include "UserMysql.h"
#include <QWidget>
#include <QList>
#include <QSqlQuery>
#include <QSettings>
#include <QLineEdit>
#include <QLabel>
#include <QMouseEvent>

//class SignUpwidget;



namespace Ui {
class Login_ly;
}

class Login_ly : public QWidget
{
    Q_OBJECT

public:
    explicit Login_ly(QWidget *parent = nullptr);
    ~Login_ly();

     void paintEvent(QPaintEvent *e)override;

     void savecfg();

     void loadcfg();

     void mousePressEvent(QMouseEvent *event) override;

     void mouseMoveEvent(QMouseEvent *event) override;

     void mouseReleaseEvent(QMouseEvent *event) override;

     void mk_info_dir(const QString &path);
   QString mk_dir(const QString &path, const QString &dir_name);
   void store_image( QString &path);
   void store_account_passwd(const QString &account, const QString &passwd,const QString &path);
   void read_image(const QString &path,const QString &account);
   void read_account(const QString &path,const QString &account);
   void set_comBox(const QString &path);

   void remeber_the_last_login();
     void read_the_last_login();



private slots:
    void on_regiter_clicked();
//    void Login();




    void on_autologin_clicked();

//    void updateUsername(const QString &text)
//    {
//        usernameEdit->setText(text);
//    }



    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_remember_clicked();

    void on_comboBox_currentIndexChanged(const QString &arg1);



    void on_login_clicked();

    void on_settingButton_clicked();

    void on_close_button_clicked();

private:
    Ui::Login_ly *ui;
    SignUpWidget *s;

    QSettings *m;
    QStringList NameList;
    QSqlDatabase db;
    QLineEdit *usernameEdit;
    bool isCilcked;
    QString	username;
    QString	passwd;
    QString	AutoLogin;
    QString	RemeberPasswd;

    bool remeberPasswd;
    bool autologin;
    StudentWidget *Stu = nullptr;

    UserMysql *Set= nullptr;

    bool m_dragging = false;
    QPoint m_dragPosition;

    //home_widget *Tea;



};

#endif // WIDGET_H
